<template>
    <el-dialog :title="titleMap[mode]" v-model="visible" width="85%"
                destroy-on-close @closed="$emit('closed')" align-center>
        <el-container>
        <el-header>
            <div class="left-panel">
            <!-- <el-button type="primary" @click="back">确定</el-button> -->
            </div>
            <div class="right-panel">
            <div class="right-panel-search">
                <el-input v-model="search.goods_name" placeholder="请输入产品名称" clearable @keyup.enter="upsearch"></el-input>
                <el-button type="primary" icon="el-icon-search" @click="upsearch"></el-button>
                <el-button type="primary" icon="el-icon-refresh" @click="refresh"></el-button>
            </div>
            </div>
        </el-header>
        <el-main class="nopadding">
            <scTable ref="table" row-key="id" :apiObj="apiObj" @row-click="selectionChange" stripe remoteSort remoteFilter border height="650" :params="query">
                <el-table-column width="1"></el-table-column>
                <el-table-column type="index" width="50" align="center"></el-table-column>
                <el-table-column label="物流单号" prop="logistics_code" align="center"></el-table-column>
				<el-table-column label="物流日期" prop="logistics_date" align="center"></el-table-column>
				<el-table-column label="创建人" prop="createstaff.name" align="center"></el-table-column>
				<el-table-column label="创建时间" prop="create_time" align="center"></el-table-column>
            </scTable>
        </el-main>
        </el-container>
        <template #footer>
        <el-button @click="visible = false">取 消</el-button>
        </template>
    </el-dialog>
</template>

<script>
export default {
    props:{
        query: { type: Object, default: () => ({}) },
    },
    emits: ['success', 'closed'],
    data() {
        return {
        mode: "add",
        titleMap: {
            add: '选择装箱单',
            edit: '编辑产品',
            show: '查看'
        },
        visible: false,
        isSaveing: false,
        apiObj: this.$API.procure.internal.list,
        selection: [],
        search: {
            goods_name: null,
            goods_code: null,
            goods_spec: null,
            goods_model: null,
            material_code: null,
        },
        data: []
        }
    },
    mounted() {
        this.getShop()
    },
    methods: {
        // 显示
        open(mode = 'add') {
            this.mode = mode;
            this.visible = true;
            return this
        },
        // 表单注入数据
        setData(data) {
            this.type = data
        },
        // 选择事件
        selectionChange(selection) {
            this.$emit('success', selection)
            this.visible = false;
        },
        // 选中返回
        back() {
            this.$emit('success', this.selection, this.type)
            this.visible = false;
        },
        //搜索
        upsearch() {
            this.$refs.table.upData(this.search)
        },
        refresh() {
            for (const key in this.search) {
                this.search[key] = null;
            }
            this.$refs.table.upData(this.search)
        },
        async getShop() {
            var res = await this.$API.procure.plan.shop.get();
            this.data = res.data
        },
    }
}
</script>

<style></style>
